Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: consolidate matching buy account id selection logic #6268

Merged
merged 3 commits into from
Feb 21, 2024

Conversation

woodenfurniture
Copy link
Member

@woodenfurniture woodenfurniture commented Feb 21, 2024

Description

Follows up on #6263 which fixed some issue with matching buyAccountId logic, but still had an issue where quotes are not fetched when selecting AVAX as the sell asset, due to incorrect default buy account being selected based on the incorrect chain ID.

3 fixes to buy account ID selection:

  1. ensure the account id selected is for the correct chainId
  2. match the buy account ID to the sell account ID based on the account number
  3. ensure last-resort default for buy account is account 0 (not highest balance account)

Pull Request Type

  • 🐛 Bug fix (Non-breaking Change: Fixes an issue)
  • 🛠️ Chore (Non-breaking Change: Doc updates, pkg upgrades, typos, etc..)
  • 💅 New Feature (Breaking/Non-breaking Change)

Issue (if applicable)

unblocks release #6257

Risk

High Risk PRs Require 2 approvals

High risk, modifies account selection.

What protocols, transaction types or contract interactions might be affected by this PR?

Testing

  • Ensure account selection is sane in terms of defaults (see changes made in description above)
  • Ensure switching assets maintains sane account selection
  • Ensure selected account is the one used to trade

Engineering

Operations

Screenshots (if applicable)

Release - no quotes being fetched:
image

Local - quotes now get fetched:
image

Last resort default is now account 0 for buy account (not highest_balance_account ?? account_0 ):
image

@woodenfurniture woodenfurniture marked this pull request as ready for review February 21, 2024 03:52
@woodenfurniture woodenfurniture requested a review from a team as a code owner February 21, 2024 03:52
@MBMaria MBMaria mentioned this pull request Feb 21, 2024
Copy link
Member

@0xApotheosis 0xApotheosis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will need further ops testing, but I can no longer replicate the issue in release.

Further:

✅ Accounts are synced on Trade component initialization
❔ Accounts are not synced on asset change, but instead retain their previous account number. This is not a bug per se, as the requirements on the desired behaviour here aren't clear/known.
✅ The buy asset account correctly defaults to account 0 when no account matching the sell asset is found
✅ The initial sell asset account is the highest balance account for the sell asset

@gomesalexandre gomesalexandre self-requested a review February 21, 2024 14:50
@gomesalexandre gomesalexandre changed the title fix: buy account id selection feat: consolidate matching buy account id selection logic Feb 21, 2024
@gomesalexandre gomesalexandre changed the title feat: consolidate matching buy account id selection logic fix: consolidate matching buy account id selection logic Feb 21, 2024
Copy link
Contributor

@gomesalexandre gomesalexandre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested locally, I wasn't able to repro in release but this is sane:

Trades out of AVAX

  • Develop (note no quotes because of amount too low, which is fine)
image
  • This diff
image

Automagical buy account selection by account number is still happy

  • Develop
image image
  • This diff
image image

@gomesalexandre gomesalexandre merged commit b477386 into release Feb 21, 2024
7 checks passed
@gomesalexandre gomesalexandre deleted the fix-avax-trades branch February 21, 2024 15:11
0xApotheosis added a commit that referenced this pull request Feb 21, 2024
* fix: trades from native assets & utxos (#6260)

fix: native allowance

* fix: use correct chain id for matching buy account

* fix: allow quote sell amounts to be lower than user input sell amount (#6265)

* fix: allow quote sell amounts to be lower than user input sell amount

* fix: fix logic, add a teeny tiny thrshold so cowswap works

* fix: consolidate matching buy account id selection logic (#6268)

* chore: fix merge

---------

Co-authored-by: kaladinlight <[email protected]>
Co-authored-by: woody <[email protected]>
gomesalexandre pushed a commit that referenced this pull request Feb 22, 2024
* fix: trades from native assets & utxos (#6260)

fix: native allowance

* fix: use correct chain id for matching buy account

* fix: allow quote sell amounts to be lower than user input sell amount (#6265)

* fix: allow quote sell amounts to be lower than user input sell amount

* fix: fix logic, add a teeny tiny thrshold so cowswap works

* fix: consolidate matching buy account id selection logic (#6268)

* chore: fix merge

---------

Co-authored-by: kaladinlight <[email protected]>
Co-authored-by: woody <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants